using UnityEngine;
using QFramework;

namespace QFramework.FlyBird
{
    public partial class Pipe : ViewController
    {
        public float Speed = 3;
        bool mScoreAdded = false;
        private void FixedUpdate()
        {
            transform.LocalPositionX(transform.localPosition.x - Speed * Time.fixedDeltaTime);
            if(transform.localPosition.x < 0 )
            {
                if(!mScoreAdded)
                {
                    AudioKit.PlaySound("Score");
                    FlappyBird.Score.Value++;
                    mScoreAdded = true;
                }
            }
            if(transform.localPosition.x < -20 )
            {
                PipeGenerator.PipePool.Recycle(this);
            }
        }
        public void ResetData()
        {
            mScoreAdded = false;
            this.Hide();
        }
    }
}
